#ifndef __PLANE_H__
#define __PLANE_H__

#include "Vector3.h"

class Plane
{
public:
	// construction
	Plane();
	Plane( const Vector3& normal, Real constant );
	Plane( const Vector3& normal, const Vector3& point );
	Plane( const Vector3& point0, const Vector3& point1,
		const Vector3& point2 );

	Vector3& normal();
	const Vector3& normal() const;

	Real& constant();
	const Real& constant() const;

	// The positive side of the plane is the half space to which the plan
	// normal points. The negative side is the other half space. The flag
	// "no side" is plane itself.

	enum Side
	{
		NO_SIDE,
		POSITIVE_SIDE,
		NEGATIVE_SIDE
	};

	Side which_side( const Vector3& point ) const;

	// The sign of the return value is positive if
	// point is on the positive side of the plane,
	// negative if the point is on the negative side,
	// and zero if the point is on the plane.

	Real distance_to( const Vector3& point ) const;

protected:
	// plane is dot( m_normal, (x,y,z) ) = m_constant
	Vector3 m_normal;
	Real m_constant;
};

#include "Plane.inl"

#endif


